import React, { Component } from 'react';
import '../../components/Home/Content.scss';
import { home_goodlist } from '../../utils/api.js'
import { Skeleton } from 'antd-mobile'

class content extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            list: [

            ],

        }
    }
    todetails(item) {
        this.props.history.push({ pathname: '/details', state: { id: item.id } })
    }
    isDisplay() {
        if (this.state.list) {
            return false;
        } else {
            return true;
        }
    }
    render() {
        return (

            <div className='content'>
                {
                    this.state.list.map((item, index) => {
                        return (
                            <div className='cate' key={index} onClick={() => { this.todetails(item) }}>
                                <img src={item.pic} alt="" />
                                <p>{item.name}</p>
                                <p>原价￥<span>{9999}</span></p>
                                <p>抢购价￥<span>{parseInt(item.salesPrice.value)}</span></p>
                            </div>
                        )
                    })
                }
            </div>
        );
    }
    componentDidMount() {
        home_goodlist({ page: 1, count: 10 }).then((res) => {
            console.log("商品列表", res.data.list)

            this.setState({
                list: res.data.list,
            })
        })

    }
}

export default content;